<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <ul id="parent-list">
        <li id="post-1">Item 1</li>
        <li id="post-2">Item 2</li>
        <li id="post-3">Item 3</li>
        <li id="post-4">Item 4</li>
        <li id="post-5">Item 5</li>
        <li id="post-6">Item 6</li>
    </ul>
    <button id="addLi">添加一个li</button>
</body>
<script>
var ul = document.getElementById('parent-list')
ul.onclick = function(e){
	//e.target是被点击的元素
    //如果被点击的是li元素
    console.log(e.target, e.target.nodeName)
	if(e.target && e.target.nodeName == 'LI') {
        alert(e.target.innerHTML)
	}
}    
document.getElementById('addLi').onclick = function(){
    var li = document.createElement('li');
    li.innerHTML = 'Item new';
    ul.appendChild(li);
}
</script>
</html>